package unq.edu.cui.tp.arena;
import org.uqbar.arena.actions.MessageSend;
import org.uqbar.arena.aop.windows.TransactionalDialog;
import org.uqbar.arena.layout.ColumnLayout;
import org.uqbar.arena.widgets.Button;
import org.uqbar.arena.widgets.Label;
import org.uqbar.arena.widgets.Panel;
import org.uqbar.arena.widgets.Selector;
import org.uqbar.arena.widgets.TextBox;
import org.uqbar.arena.windows.WindowOwner;

import unq.edu.cui.tp.dominio.Empleado;
import unq.edu.cui.tp.modelo.ventanas.AgregarDisponibilidad;

public class AgregarDisponibilidadWindow extends TransactionalDialog<AgregarDisponibilidad> {

	public AgregarDisponibilidadWindow(WindowOwner owner, Empleado empleado) {
        super(owner, new AgregarDisponibilidad(empleado));
    }
	@Override
	protected void createFormPanel(Panel mainPanel) {
		Panel form = new Panel(mainPanel);
    	form.setLayout(new ColumnLayout(2));
        this.setTitle("Crear disponibilidad");
         
        new Label(form).setText("Desde");
        new TextBox(form).setWidth(70).bindValueToProperty("dia.desde");
        
        new Label(form).setText("Hasta");
        new TextBox(form).setWidth(70).bindValueToProperty("dia.hasta");
        
        new Label(form).setText("Dia");
        Selector dias= new Selector<String>(form);
        dias.bindItemsToProperty("diasPosibles");
        dias.setWidth(100).bindValueToProperty("dia.nombreDia");
        
        new Button(form).setCaption("Aceptar").onClick(new MessageSend(this, "agregarDiaDisponible"));
        new Button(form).setCaption("Cancelar").onClick(new MessageSend(this, "cancel"));
		
	}
	
	public void agregarDiaDisponible(){
		this.getModelObject().agregarDiaDisponible();
		this.accept();
	}

}

